package lumis.service.wsrp.producer;

import java.util.Date;

import lumis.doui.processaction.ProcessActionHandler;
import lumis.doui.source.Source;
import lumis.portal.PortalException;
import lumis.portal.manager.ManagerFactory;

/**
 * Process Action used to update date lifetime.
 * @version $Revision: 13092 $ $Date: 2011-05-28 18:19:06 -0300 (Sat, 28 May 2011) $
 * @since 6.0.0
 */
public class EditLifetimeProcessActionHandler extends ProcessActionHandler<Source<?>> 
{
	
	public void processAction() throws PortalException
	{
		//gets the parameters to update database
		String registrationHandle = getParameter("registrationHandle", String.class);
		Date lifetimeTermination = getParameter("lifetimeTerminationTime", Date.class);
		
		//finds the register and sets new lifetime
		RemoteConsumerRegistration consumerRegistration = ManagerFactory.getEntityManager().find(RemoteConsumerRegistration.class, registrationHandle);
		consumerRegistration.setLifetimeTerminationTime(lifetimeTermination);
		addDefaultResponse();
	}
}
